/******************************************************************************
 * 
 * Announce: CSharpKit, Basic algorithms, components and definitions.
 *           Copyright (C) ShenYongchen.
 *           All rights reserved.
 *   Author: 申永辰.郑州 (shenyczz@163.com)
 *  WebSite: http://gitee.com/shenyczz/csharp_csk
 *
 * THIS CODE IS LICENSED UNDER THE MIT LICENSE (MIT).
 * THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF 
 * ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
 * IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
 * PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
 * 
******************************************************************************/

using System;

namespace CSharpKit.NTS.Geometries
{
    /// <summary>
    /// Coordinate - 坐标
    /// </summary>
    [Serializable]
    public sealed class Coordinate : Target, ICloneable<Coordinate>, IComparable<Coordinate>, IEquatable<Coordinate>
    {
        public Coordinate()
            : this(0, 0) { }

        public Coordinate(double x, double y)
            : this(x, y, NULL_ORDINATE) { }

        public Coordinate(double x, double y, double z)
        {
            this.x = x;
            this.y = y;
            this.z = z;
        }

        private Coordinate(Coordinate rhs)
        {
            this.x = rhs.x;
            this.y = rhs.y;
            this.z = rhs.z;
            this.m = rhs.m;
        }

        /// <summary>
        ///  空坐标
        /// </summary>
        public static readonly double NULL_ORDINATE = double.NaN;
        public static readonly int X = 0;
        public static readonly int Y = 1;
        public static readonly int Z = 2;
        public static readonly int M = 3;

        /// <summary>
        /// x-ordinate.
        /// </summary>
        public double x { get; set; }
        public double y { get; set; }
        public double z { get; set; }
        public object m { get; set; }




        public Coordinate Clone()
        {
            return new Coordinate(this);
        }

        public int CompareTo(Coordinate other)
        {
            if (x < other.x) return -1;
            if (x > other.x) return 1;
            if (y < other.y) return -1;
            if (y > other.y) return 1;
            return 0;
        }

        public bool Equals(Coordinate other)
        {
            throw new NotImplementedException();
        }


        public Boolean isValid()
        {
            if (!Double.IsFinite(x)) return false;
            if (!Double.IsFinite(y)) return false;
            return true;
        }



        // {{END}}
    }

}
